home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / flex_2_3 / part01 next >
Encoding:
Internet Message Format  |  1990-08-19  |  65.0 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i228: flex 2.3 - fast lexical analyzer generator, Part01/13
  4. Reply-To: loftus@wpllabs.uucp (William P Loftus)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i228@abcfd20.larc.nasa.gov>
  7. Date: 19 Aug 90 22:41:53 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: loftus@wpllabs.uucp (William P Loftus)
  13. Posting-number: Volume 90, Issue 228
  14. Archive-name: unix/flex-2.3/part01
  15.  
  16. [ the flexdoc.doc file was uuencoded to preserve formatting, and it
  17.   and flexdoc.1 were split ...tad ]
  18.  
  19. [ from the flexdoc file... ]
  20.  
  21.      flex is a  tool  for  generating  scanners:  programs  which
  22.      recognized  lexical  patterns in text.  flex reads the given
  23.      input files, or its standard input  if  no  file  names  are
  24.      given,  for  a  description  of  a scanner to generate.  The
  25.      description is in the form of pairs of  regular  expressions
  26.      and  C  code,  called  rules.  flex  generates as output a C
  27.      source file, lex.yy.c, which defines a routine yylex(). This
  28.      file is compiled and linked with the -lfl library to produce
  29.      an executable.  When the executable is run, it analyzes  its
  30.      input  for occurrences of the regular expressions.  Whenever
  31.      it finds one, it executes the corresponding C code.
  32.  
  33. #!/bin/sh
  34. # This is a shell archive.  Remove anything before this line, then unpack
  35. # it by saving it into a file and typing "sh file".  To overwrite existing
  36. # files, type "sh file -c".  You can also feed this as standard input via
  37. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  38. # will see the following message at the end:
  39. #        "End of archive 1 (of 13)."
  40. # Contents:  Amiga.notes COPYING MISC MISC/MSDOS.notes
  41. #   MISC/Makefile.VMS MISC/README MISC/Turbo-C.notes Makefile
  42. #   Makefile.amiga README ccl.c ecs.c flexdoc.uu.ac libmain.c parse.h
  43. #   sym.c yylex.c
  44. # Wrapped by tadguy@abcfd20 on Sun Aug 19 18:41:41 1990
  45. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  46. if test -f 'Amiga.notes' -a "${1}" != "-c" ; then 
  47.   echo shar: Will not clobber existing file \"'Amiga.notes'\"
  48. else
  49. echo shar: Extracting \"'Amiga.notes'\" \(1144 characters\)
  50. sed "s/^X//" >'Amiga.notes' <<'END_OF_FILE'
  51. X(1) Makefile modifications
  52. X
  53. X  o Removed Unix depended commands and conventions
  54. X
  55. X  o Made Makefile bison specific (isn't there a bison option to make it act like
  56. X  yacc, i.e., generate y.tab.c instead of parse.tab.c?)
  57. X
  58. X  o Amiga Makefile is called "Makefile.amiga"
  59. X
  60. X(2) flexdef.h modifications (because of makefile problem)
  61. X
  62. X  o Cannot get quotes to work correctly with AmigaDOS and LMK.               
  63. X  moved this define to flexdef.h (between ifdef AMIGA...endif) wpl 7/14/90 
  64. X
  65. X  Affected makefile line:
  66. X    #SKELFLAGS = -dDEFAULT_SKELETON_FILE="$(SKELETON_FILE)"
  67. X
  68. X(3) parse.y
  69. X
  70. X  o Added following prototypes:
  71. X
  72. X      void build_eof_action(); 
  73. X      void yyerror( char * );
  74. X
  75. X(4) scan.l
  76. X
  77. X  o Added case "return ( (int) yytext[0] )"
  78. X
  79. X(5) flex.skel
  80. X
  81. X  o Added keyword "register" to following prototypes:
  82. X
  83. X      static yy_state_type yy_try_NUL_trans 
  84. X         YY_PROTO(( register yy_state_type current_state ));
  85. X
  86. X      static void yyunput YY_PROTO(( YY_CHAR c, 
  87. X         register YY_CHAR *buf_ptr ));
  88. X
  89. X(6)  main.c
  90. X
  91. X  o changed mktemp call to a call to TmpFileName and added TmpFileName
  92. X    routine.
  93. X
  94. X    char *                
  95. X    TmpFileName(template)
  96. X
  97. END_OF_FILE
  98. if test 1144 -ne `wc -c <'Amiga.notes'`; then
  99.     echo shar: \"'Amiga.notes'\" unpacked with wrong size!
  100. fi
  101. # end of 'Amiga.notes'
  102. fi
  103. if test -f 'COPYING' -a "${1}" != "-c" ; then 
  104.   echo shar: Will not clobber existing file \"'COPYING'\"
  105. else
  106. echo shar: Extracting \"'COPYING'\" \(1802 characters\)
  107. sed "s/^X//" >'COPYING' <<'END_OF_FILE'
  108. XFlex carries the copyright used for BSD software, slightly modified
  109. Xbecause it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
  110. Xwhich operates under a contract with the Department of Energy:
  111. X
  112. X    Copyright (c) 1990 The Regents of the University of California.
  113. X    All rights reserved.
  114. X
  115. X    This code is derived from software contributed to Berkeley by
  116. X    Vern Paxson.
  117. X
  118. X    The United States Government has rights in this work pursuant
  119. X    to contract no. DE-AC03-76SF00098 between the United States
  120. X    Department of Energy and the University of California.
  121. X
  122. X    Redistribution and use in source and binary forms are permitted
  123. X    provided that: (1) source distributions retain this entire
  124. X    copyright notice and comment, and (2) distributions including
  125. X    binaries display the following acknowledgement:  ``This product
  126. X    includes software developed by the University of California,
  127. X    Berkeley and its contributors'' in the documentation or other
  128. X    materials provided with the distribution and in all advertising
  129. X    materials mentioning features or use of this software.  Neither the
  130. X    name of the University nor the names of its contributors may be
  131. X    used to endorse or promote products derived from this software
  132. X    without specific prior written permission.
  133. X
  134. X    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  135. X    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  136. X    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  137. X    PURPOSE.
  138. X
  139. XThis basically says "do whatever you please with this software except
  140. Xremove this notice or take advantage of the University's (or the flex
  141. Xauthors') name".
  142. X
  143. XNote that the "flex.skel" scanner skeleton carries no copyright notice.
  144. XYou are free to do whatever you please with scanners generated using flex;
  145. Xfor them, you are not even bound by the above copyright.
  146. END_OF_FILE
  147. if test 1802 -ne `wc -c <'COPYING'`; then
  148.     echo shar: \"'COPYING'\" unpacked with wrong size!
  149. fi
  150. # end of 'COPYING'
  151. fi
  152. if test ! -d 'MISC' ; then
  153.     echo shar: Creating directory \"'MISC'\"
  154.     mkdir 'MISC'
  155. fi
  156. if test -f 'MISC/MSDOS.notes' -a "${1}" != "-c" ; then 
  157.   echo shar: Will not clobber existing file \"'MISC/MSDOS.notes'\"
  158. else
  159. echo shar: Extracting \"'MISC/MSDOS.notes'\" \(5328 characters\)
  160. sed "s/^X//" >'MISC/MSDOS.notes' <<'END_OF_FILE'
  161. X$Header:$
  162. X
  163. XNotes on Porting flex to MS-DOS
  164. X-------------------------------
  165. X
  166. X[These notes were last revised 30Dec89 for flex release 2.2.]
  167. X
  168. XPrevious releases of flex have been successfully built using Microsoft C and
  169. Xthe following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V
  170. X
  171. XOther folks report that the following work for MSC 5.1 under DOS and OS/2:
  172. X
  173. X    CFLAGS=-ALu -F 8000 -Gt16000 -Ox -DMS_DOS -DSYS_V -D__RUNTIME_YYMAXDEPTH
  174. X    LINKFLAGS=/E /FAR /PAC /NOI
  175. X
  176. XWhere you may want to adjust -F up in order to increase available stack
  177. Xsize (though it may not be necessary) and you may want to increase -Gt
  178. Xto some number that puts just enought of the big data items in their own
  179. Xdata segments.  (The default for -Gt is items of 32k.  This is too high for
  180. Xflex.)  __RUNTIME_YYMAXDEPTH is useful if you have a parse.c that's
  181. Xbeen generated by a yacc that understands how to do this; otherwise, it's a
  182. Xno-op.
  183. X
  184. XJeffrey R. Jones (jjones@angate.att.com) writes [this has been edited -vp]:
  185. X
  186. X.... The port was accomplished with:
  187. X
  188. X        AT&T 6312 WGS (12 Mhz AT class machine)
  189. X        Microsoft C compiler Version 5.0
  190. X        'make' utility from Aztec-C package (subset of unix-make)
  191. X
  192. XThe re-done makefile is included ....  Do what you wish with it.
  193. X
  194. X
  195. X[note that this Makefile is now slightly out of date and has not been
  196. X tested with flex 2.2]
  197. X
  198. X# This makefile is used to port the flex 2.1 build to a PC.  The compiler is
  199. X# Microsoft-C Version 5.0 while the 'make' utility came with Aztec-C, which
  200. X# is VERY compatible with Unix's make.  There are a few things that Aztec-C's
  201. X# 'make' can't do that unix does so I have made a few minor changes.
  202. X# At the least you can manually compile each file and then link.
  203. X# The linker and library utilities are alos Microsoft's.
  204. X#
  205. X# Additionally, after building with the large model, the flex.map reveals that
  206. X# code-size is less than 64K, therefore, in favor of a little more execution
  207. X# efficiency, I built with the compact model.  I've used the default compiler
  208. X# optimization (no /O switches).
  209. X#
  210. X# The linker must be told to increase the run-time stack space.  The default
  211. X# stack space is 2048.  Flexing scan.l with the default stack-space results in
  212. X# a run-time stack overflow, hence the stack was increase to 4096.
  213. X#
  214. X# NOTE: I have MKS-Toolkit's yacc and was able to use it with virtually no
  215. X# modifications to anything.  If you don't have yacc for a PC, you can try
  216. X# yaccing on a unix system and downloading the resulting files to the PC.
  217. X#
  218. X#            Jeffrey R. Jones
  219. X#            jjones@angate!att.com
  220. X
  221. X
  222. X# make file for "flex" tool
  223. X
  224. X# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
  225. X
  226. X# Porting considerations:
  227. X#
  228. X#    For System V Unix machines, add -DSYS_V to CFLAGS.
  229. X#    For Vax/VMS, add -DSYS_V to CFLAGS.
  230. X#    For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS.  Create \tmp if not present.
  231. X#         You will also want to rename flex.skel to something with a three
  232. X#         character extension, change SKELETON_FILE below appropriately,
  233. X#    For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS.
  234. X
  235. X
  236. X# the first time around use "make first_flex"
  237. X
  238. X
  239. XYACC=yacc
  240. XSKELETON_DIR = c:/usr/contrib/lib
  241. XSKELETON_FILE = flex.ske
  242. XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  243. XCFLAGS = -c -AC -DMS_DOS -DSYS_V
  244. XLDFLAGS = /noi /cp:1 /stack:4096
  245. X
  246. X#this null definition prevents a returned error code
  247. XMFLAGS =
  248. X
  249. XFLEX_FLAGS =
  250. XFLEX = flex
  251. XCC = cl
  252. X
  253. X# redefine Aztec make's built-in rule
  254. X.c.obj:
  255. X    $(CC) $(CFLAGS) $*.c
  256. X
  257. X# break obj-list into two because of 128 character command-line limit of
  258. X# Microsoft's link and lib utilities.
  259. XFLEXOBJS1 = ccl.obj dfa.obj ecs.obj gen.obj main.obj misc.obj nfa.obj parse.obj
  260. XFLEXOBJS2 = scan.obj sym.obj tblcmp.obj yylex.obj
  261. X
  262. XFLEX_C_SOURCES = \
  263. X    ccl.c \
  264. X    dfa.c \
  265. X    ecs.c \
  266. X    gen.c \
  267. X    main.c \
  268. X    misc.c \
  269. X    nfa.c \
  270. X    parse.c \
  271. X    scan.c \
  272. X    sym.c \
  273. X    tblcmp.c \
  274. X    yylex.c
  275. X
  276. X# lib is used to get around the 128 character command-line limit of 'link'.
  277. Xflex.exe : $(FLEXOBJS1) $(FLEXOBJS2)
  278. X    lib tmplib $(FLEXOBJS1);
  279. X    link $(LDFLAGS) $(FLEXOBJS2),$*.exe,,tmplib;
  280. X    rm -f tmplib.lib
  281. X
  282. X# the second 'make flex.exe' causes scan.l to be RE-flexed.  The resulting
  283. X# scan.c is different from initscan.c in that \r\n are added instead of
  284. X# just \n.  Since \r\n is DOS language and this is targetted for PCs, and
  285. X# since I don't know what would happen for all cases in DOS-land, I went
  286. X# ahead and did it.
  287. Xfirst_flex:
  288. X    cp initscan.c scan.c
  289. X    make $(MFLAGS) flex.exe
  290. X    rm -f scan.c
  291. X    make flex.exe
  292. X
  293. Xparse.obj: parse.c parse.h
  294. X
  295. Xparse.h parse.c : parse.y
  296. X    $(YACC) -d parse.y
  297. X    @mv ytab.c parse.c
  298. X    @mv ytab.h parse.h
  299. X
  300. Xscan.c : scan.l
  301. X    $(FLEX) -ist $(FLEX_FLAGS) scan.l > scan.c
  302. X
  303. Xscan.obj : scan.c parse.h
  304. X
  305. Xmain.obj : main.c
  306. X    $(CC) $(CFLAGS) $(SKELFLAGS) main.c
  307. X
  308. X###################
  309. X#don't have, or need, anything else except maybe the 'test' rule.
  310. X#
  311. X# don't have nroff
  312. X#flex.man : flex.1
  313. X#    nroff -man flex.1 >flex.man
  314. X#
  315. X# don't have lint
  316. X#lint : $(FLEX_C_SOURCES)
  317. X#    lint $(FLEX_C_SOURCES) > flex.lint
  318. X#
  319. X#distrib :
  320. X#    mv scan.c initscan.c
  321. X#    chmod 444 initscan.c
  322. X#    $(MAKE) $(MFLAGS) clean
  323. X#
  324. X#clean :
  325. X#    rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags
  326. X#
  327. X#tags :
  328. X#    ctags $(FLEX_C_SOURCES)
  329. X#
  330. X#vms :    flex.man
  331. X#    $(MAKE) $(MFLAGS) distrib
  332. X#
  333. X# break this up into multiple lines...Aztec 'make' limitation
  334. Xtest :
  335. X    $(FLEX) -ist $(FLEX_FLAGS) scan.l > scan.tst
  336. X    diff scan.c scan.tst
  337. X    rm -f scan.tst
  338. END_OF_FILE
  339. if test 5328 -ne `wc -c <'MISC/MSDOS.notes'`; then
  340.     echo shar: \"'MISC/MSDOS.notes'\" unpacked with wrong size!
  341. fi
  342. # end of 'MISC/MSDOS.notes'
  343. fi
  344. if test -f 'MISC/Makefile.VMS' -a "${1}" != "-c" ; then 
  345.   echo shar: Will not clobber existing file \"'MISC/Makefile.VMS'\"
  346. else
  347. echo shar: Extracting \"'MISC/Makefile.VMS'\" \(3537 characters\)
  348. sed "s/^X//" >'MISC/Makefile.VMS' <<'END_OF_FILE'
  349. X############################ VMS MAKEFILE ##############################
  350. X#IMPORTANT:  Before you use this makefile fill in the contents of GNULIB.
  351. X#
  352. X# Define tools$$exe, tools$$library, and tools$$manual to reflect the 
  353. X# locations where you would like to store the executables, library (flex.skel)
  354. X# and the manual pages.  These names can be defined at the command line
  355. X# prompt:  eg.
  356. X#    $ define tools$$exe disk:[dir1.dir2.etc]
  357. X#   
  358. X# Once these names have been defined the following commands
  359. X# can be executed at the command line:
  360. X#
  361. X#   $ mms install
  362. X#   $ mms test
  363. X#   $ mms clean
  364. X#
  365. X# When "mms test" is executed the diff should not show any differences. In fact
  366. X# the same effect can be achieved by
  367. X#
  368. X#   $ mms install, test, clean
  369. X#
  370. X#  The filename of the the mms description file, i.e., this file,
  371. X#  should either be "makefile." or "decrip.mms"
  372. X#
  373. X# VMS make file for "flex" tool
  374. X
  375. X# Redefine the following for your own environment
  376. XBIN = tools$$exe
  377. XLIB = tools$$library
  378. XMAN = tools$$manual
  379. XGNULIB = <******directory where you keep alloca.obj and bcopy.obj***>
  380. X
  381. XSKELETON_FILE = "DEFAULT_SKELETON_FILE=""$(LIB):FLEX.SKEL"""
  382. X
  383. XCCFLAGS = VMS,USG
  384. XFLEX_FLAGS = -is
  385. X
  386. XFLEXOBJS = ccl.obj dfa.obj ecs.obj gen.obj main.obj misc.obj nfa.obj  -
  387. X           parse.obj scan.obj sym.obj tblcmp.obj yylex.obj 
  388. X
  389. XOBJ = ccl.obj,dfa.obj,ecs.obj,gen.obj,main.obj,misc.obj,nfa.obj,parse.obj, -
  390. X      scan.obj,sym.obj,tblcmp.obj,yylex.obj
  391. X
  392. Xdefault : flex
  393. X    ! installed FLEX
  394. X
  395. Xinstall : lib man bin 
  396. X    !Installed FLEX and LIBRARIES
  397. X
  398. Xlib : $(LIB):flex.skel
  399. X    ! Installed $(LIB):flex.skel
  400. X
  401. Xbin : $(BIN):flex.exe
  402. X    flex :== $ $(BIN):flex.exe
  403. X
  404. Xman : $(MAN):flex.doc
  405. X    ! installed $(MAN):flex.doc
  406. X
  407. X$(LIB):flex.skel : flex.skel
  408. X    copy flex.skel $(LIB):flex.skel
  409. X$(BIN):flex.exe : flex.exe
  410. X    copy flex.exe $(BIN):flex.exe
  411. X$(MAN):flex.doc : flex.1
  412. X    copy flex.1 $(MAN):flex.doc
  413. X
  414. Xflex : flex.exe
  415. X    copy flex.exe $(BIN):flex.exe
  416. X
  417. Xflex.exe : $(FLEXOBJS)
  418. X    link /exe=flex.exe -
  419. X        $(OBJ),  -
  420. X        $(GNULIB)alloca.obj,  -
  421. X        $(GNULIB)bcopy.obj
  422. X
  423. X
  424. Xparse.c : parse.y
  425. X    bison/defines/verbose/fixed_outfiles parse.y
  426. X    copy y_tab.c parse.c
  427. X    del/noconfirm y_tab.c;*
  428. X
  429. Xparse.h : parse.c
  430. X    copy y_tab.h parse.h
  431. X    del/noconfirm y_tab.h;*
  432. X
  433. Xscan.c : initscan.c
  434. X    copy initscan.c scan.c
  435. X
  436. Xccl.obj : ccl.c flexdef.h
  437. X    cc /define=($(CCFLAGS)) ccl.c
  438. Xdfa.obj : dfa.c flexdef.h
  439. X    cc /define=($(CCFLAGS)) dfa.c
  440. Xecs.obj : ecs.c flexdef.h
  441. X    cc /define=($(CCFLAGS)) ecs.c
  442. Xgen.obj : gen.c flexdef.h
  443. X    cc /define=($(CCFLAGS)) gen.c
  444. Xmain.obj : main.c flexdef.h
  445. X    cc /define=($(CCFLAGS),$(SKELETON_FILE)) main.c
  446. Xmisc.obj : misc.c flexdef.h
  447. X    cc /define=($(CCFLAGS)) misc.c
  448. Xnfa.obj : nfa.c flexdef.h
  449. X    cc /define=($(CCFLAGS)) nfa.c
  450. Xparse.obj : parse.c flexdef.h parse.h
  451. X    cc /define=($(CCFLAGS)) parse.c
  452. Xscan.obj : scan.c parse.h flexdef.h
  453. X    cc /define=($(CCFLAGS)) scan.c
  454. Xsym.obj : sym.c flexdef.h
  455. X    cc /define=($(CCFLAGS)) sym.c
  456. Xtblcmp.obj : tblcmp.c flexdef.h
  457. X    cc /define=($(CCFLAGS)) tblcmp.c
  458. Xyylex.obj : yylex.c parse.h flexdef.h
  459. X    cc /define=($(CCFLAGS)) yylex.c
  460. X
  461. Xclean :
  462. X    ! Cleaning up by deleting unnecessary object files etc.
  463. X    - delete/noconfirm scan.c;*
  464. X    - delete/noconfirm parse.c;*
  465. X    - delete/noconfirm parse.h;*
  466. X    - delete/noconfirm lexyy.c;*
  467. X    - delete/noconfirm *.obj;*
  468. X    - delete/noconfirm flex*.tmp;*
  469. X    - delete/noconfirm y.output;*
  470. X    - delete/noconfirm *.diff;*
  471. X    - delete/noconfirm y_tab.*;*
  472. X    - purge/log
  473. X
  474. Xtest :  $(BIN):flex.exe
  475. X    flex :== $ $(BIN):flex.exe
  476. X    define tools$$library 'f$environment("default")'
  477. X    sho log tool$$library
  478. X    flex $(FLEX_FLAGS) scan.l
  479. X    diff/out=flex.diff initscan.c lexyy.c
  480. X    type/page flex.diff
  481. END_OF_FILE
  482. if test 3537 -ne `wc -c <'MISC/Makefile.VMS'`; then
  483.     echo shar: \"'MISC/Makefile.VMS'\" unpacked with wrong size!
  484. fi
  485. # end of 'MISC/Makefile.VMS'
  486. fi
  487. if test -f 'MISC/README' -a "${1}" != "-c" ; then 
  488.   echo shar: Will not clobber existing file \"'MISC/README'\"
  489. else
  490. echo shar: Extracting \"'MISC/README'\" \(520 characters\)
  491. sed "s/^X//" >'MISC/README' <<'END_OF_FILE'
  492. XMiscellaneous flex stuff.  In here you'll find:
  493. X
  494. X  - a VMS makefile for flex
  495. X
  496. X  - out-of-date patches for flex on the Atari and for Minix,
  497. X    from Ronald Lamprecht (V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU,
  498. X    ...!unido!DHDURZ1.bitnet!V61, V61@DHDURZ1 (Bitnet));
  499. X
  500. X  - somewhat out-of-date notes on porting flex to MS-DOS, from
  501. X    Jeffrey R. Jones (jjones@angate.att.com);
  502. X
  503. X  - notes on porting flex to Turbo-C, from Frank Whaley (few@quad1.quad.com,
  504. X    uunet!ccicpg!quad1!few).
  505. X
  506. XUpdated versions of these will be welcome!
  507. END_OF_FILE
  508. if test 520 -ne `wc -c <'MISC/README'`; then
  509.     echo shar: \"'MISC/README'\" unpacked with wrong size!
  510. fi
  511. # end of 'MISC/README'
  512. fi
  513. if test -f 'MISC/Turbo-C.notes' -a "${1}" != "-c" ; then 
  514.   echo shar: Will not clobber existing file \"'MISC/Turbo-C.notes'\"
  515. else
  516. echo shar: Extracting \"'MISC/Turbo-C.notes'\" \(6089 characters\)
  517. sed "s/^X//" >'MISC/Turbo-C.notes' <<'END_OF_FILE'
  518. X(Message inbox:25)
  519. XDate:  Tue, 29 Aug 89 18:57:48 pst
  520. XFrom:  few@quad1.quad.com (Frank Whaley)
  521. XSubject:  Re: flex 2.1 for Turbo C
  522. XTo:  vern@cs.cornell.edu
  523. X
  524. X> Sorry it's taken me so long to get back to you - I've been out of touch
  525. X> for about the last month.
  526. X
  527. XI didn't expect to hear from you soon -- hope your journey was nice.
  528. X
  529. X> I'd like to have your 'adjustments' for Turbo C, so if you still have
  530. X> them lying conveniently around, please mail them to me.  Thanks.
  531. X
  532. XAfter a little more fiddling, the changes are relatively small.  Probably
  533. Xthe largest problem is that Turbo C does not yet claim to adhere to the
  534. Xdraft standard, so even though they support many "modern" constructs, they
  535. Xstill are not __STDC__.  Thus the diffs from flex.skl (note the name):
  536. X
  537. X    62c62
  538. X    < #if defined(__STDC__) || defined(__TURBOC__)
  539. X    ---
  540. X    > #ifdef __STDC__
  541. X    104c104
  542. X    < #if !(defined(__STDC__) || defined(__TURBOC__))
  543. X    ---
  544. X    > #ifndef __STDC__
  545. X    134c134
  546. X    < #if defined(__STDC__) || defined(__TURBOC__)
  547. X    ---
  548. X    > #ifdef __STDC__
  549. X    390c390
  550. X    < #if defined(__STDC__) || defined(__TURBOC__)
  551. X    ---
  552. X    > #ifdef __STDC__
  553. X    482c482
  554. X    < #if defined(__STDC__) || defined(__TURBOC__)
  555. X    ---
  556. X    > #ifdef __STDC__
  557. X
  558. Xand initscan.c:
  559. X
  560. X    63c63
  561. X    < #if defined(__STDC__) || defined(__TURBOC__)
  562. X    ---
  563. X    > #ifdef __STDC__
  564. X    105c105
  565. X    < #if !(defined(__STDC__) || defined(__TURBOC__))
  566. X    ---
  567. X    > #ifndef __STDC__
  568. X    677c677
  569. X    < #if defined(__STDC__) || defined(__TURBOC__)
  570. X    ---
  571. X    > #ifdef __STDC__
  572. X    1658c1658
  573. X    < #if defined(__STDC__) || defined(__TURBOC__)
  574. X    ---
  575. X    > #ifdef __STDC__
  576. X    1750c1750
  577. X    < #if defined(__STDC__) || defined(__TURBOC__)
  578. X    ---
  579. X    > #ifdef __STDC__
  580. X
  581. Xare pretty simple.  BTW, simply adding -D__STDC__=1 to CFLAGS works, but
  582. X__STDC__ is used in many Turbo C header files, and can confuse things.
  583. XIt would also mean that all flex-generated code must be compiled with
  584. Xthat flag.
  585. X
  586. Xflexdef.h also had one small problem:
  587. X
  588. X    44,46c44
  589. X    < #ifndef MS_DOS
  590. X    < char *memset();        /*  should be declared in string.h  */
  591. X    < #endif
  592. X    ---
  593. X    > char *memset();
  594. X
  595. Xas the Turbo C definiton of memset() is:
  596. X    void *memset(void *s, int c, size_t n);
  597. X
  598. XThe 128-byte command line limit of MS-DOS prevents us from using tcc to
  599. Xlink the objects together, so I provide a tlink script, flex.lnk:
  600. X-----
  601. X\turboc\lib\c0l+
  602. Xccl+
  603. Xdfa+
  604. Xecs+
  605. Xgen+
  606. Xmain+
  607. Xmisc+
  608. Xnfa+
  609. Xparse+
  610. Xscan+
  611. Xsym+
  612. Xtblcmp+
  613. Xyylex
  614. Xflex.exe
  615. X
  616. X\turboc\lib\cl
  617. X-----
  618. X
  619. XThe blank line is required.
  620. X
  621. XThe makefile needed a lot of hacking, so here it is in its entirety.
  622. XI don't think it is completely finished, but I'll be happy to work on
  623. Xit more if you'd like.  Some of the changes are specific to my environment
  624. X(my yacc outputs ytab.c and ytab.h) and most MS-DOS people won't have
  625. Xcp, mv and rm.  Some people like separate makefiles for different
  626. Xsystems, but we like one makefile with obscene parameterization.
  627. X
  628. XI should note that all of my experiments with FLEX_FLAGS=-{c,f,F,e}
  629. Xhave failed, mostly due to scan.c becoming too large to be a single
  630. Xmodule.  Damn toy operating system.
  631. X-----
  632. X# make file for "flex" tool
  633. X
  634. X# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
  635. X
  636. X# Porting considerations:
  637. X#
  638. X#    For BSD machines:
  639. X#  CFLAGS =
  640. X#  LDFLAGS = -s
  641. X#  LINK = $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
  642. X#  SKELETON_DIR = .
  643. X#  SKELETON_FILE = flex.skel
  644. X#  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  645. X#  O = o
  646. X#  YTAB = y.tab
  647. X#  FLEX = ./flex
  648. X#
  649. X#    For System V Unix or Vax/VMS machines, merely add:
  650. X#  CFLAGS = -DSYS_V
  651. X#
  652. X#    For MS-DOS, Turbo C:
  653. XCC = tcc
  654. XCFLAGS = -DSYS_V -DMS_DOS -O -G -Z -ml -v
  655. XLINK = tlink @flex.lnk/c/x/v
  656. XSKELETON_DIR = .
  657. XSKELETON_FILE = flex.skl
  658. XSKELFLAGS = -DDEFAULT_SKELETON_FILE="$(SKELETON_DIR)/$(SKELETON_FILE)"
  659. XO = obj
  660. XEXE = .exe
  661. XYTAB = ytab
  662. XFLEX = flex
  663. X
  664. X#
  665. X# the first time around use "make first_flex"
  666. X#
  667. X
  668. XFLEX_FLAGS =
  669. X
  670. XFLEXOBJS = \
  671. X    ccl.$O \
  672. X    dfa.$O \
  673. X    ecs.$O \
  674. X    gen.$O \
  675. X    main.$O \
  676. X    misc.$O \
  677. X    nfa.$O \
  678. X    parse.$O \
  679. X    scan.$O \
  680. X    sym.$O \
  681. X    tblcmp.$O \
  682. X    yylex.$O
  683. X
  684. XFLEX_C_SOURCES = \
  685. X    ccl.c \
  686. X    dfa.c \
  687. X    ecs.c \
  688. X    gen.c \
  689. X    main.c \
  690. X    misc.c \
  691. X    nfa.c \
  692. X    parse.c \
  693. X    scan.c \
  694. X    sym.c \
  695. X    tblcmp.c \
  696. X    yylex.c
  697. X
  698. Xflex$(EXE): $(FLEXOBJS)
  699. X    $(LINK)
  700. X
  701. Xfirst_flex:
  702. X    cp initscan.c scan.c
  703. X    $(MAKE) flex$(EXE)
  704. X
  705. Xparse.h parse.c: parse.y
  706. X    $(YACC) -d parse.y
  707. X    @mv $(YTAB).c parse.c
  708. X    @mv $(YTAB).h parse.h
  709. X
  710. Xscan.c: scan.l
  711. X    $(FLEX) -ist $(FLEX_FLAGS) scan.l >scan.c
  712. X
  713. Xscan.$O: scan.c parse.h
  714. X
  715. Xmain.$O: main.c
  716. X    $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
  717. X
  718. Xflex.man: flex.1
  719. X    nroff -man flex.1 >flex.man
  720. X
  721. Xlint: $(FLEX_C_SOURCES)
  722. X    lint $(FLEX_C_SOURCES) > flex.lint
  723. X
  724. Xdistrib:
  725. X    mv scan.c initscan.c
  726. X    chmod 444 initscan.c
  727. X    $(MAKE) clean
  728. X
  729. Xclean:
  730. X    rm -f core errs flex *.$O parse.c *.lint parse.h flex.man tags
  731. X
  732. Xtags:
  733. X    ctags $(FLEX_C_SOURCES)
  734. X
  735. Xvms:    flex.man
  736. X    $(MAKE) distrib
  737. X
  738. Xtest:
  739. X    $(FLEX) -ist $(FLEX_FLAGS) scan.l | diff scan.c -
  740. X-----
  741. X
  742. XBTW, thanks for a great tool.
  743. X
  744. XFrank Whaley
  745. XSenior Development Engineer
  746. XQuadratron Systems Incorporated
  747. Xfew@quad1.quad.com
  748. Xuunet!ccicpg!quad1!few
  749. X(Message inbox:8)
  750. XDate:  Thu, 31 Aug 89 14:57:36 pst
  751. XFrom:  few@quad1.quad.com (Frank Whaley)
  752. XSubject:  Re: flex 2.1 for Turbo C
  753. XTo:  vern@cs.cornell.edu
  754. X
  755. X> Thanks for the diffs and Makefile.  I'll endeavor to integrate them
  756. X> into the next release.
  757. X
  758. XOne terribly important thing I forgot -- Turbo C (and most MS-DOS C
  759. Xcompilers) provide only a 4K default stack.  Not having thoroughly
  760. Xtested flex, I can't say that this is enough.  The makefile I provided
  761. Xto you builds a version without stack checking code.  I would suggest
  762. Xadding "-N" to CFLAGS, which will include some simple stack overflow
  763. Xchecking code.  You may wish to include the following lines to main.c:
  764. X
  765. X    #ifdef __TURBOC__
  766. X    unsigned _stklen = 16384;    /*  some reasonably large number  */
  767. X    #endif
  768. X
  769. XIn addition, the flags in the makefile build a version with symbols
  770. Xfor Turbo Debugger (like -g).  You may wan't to leave these flags off
  771. X(remove "-v" from CFLAGS and "/v" from LINK) or you may wish to provide
  772. Xan "install" target like so:
  773. X
  774. X    BINDIR = {/usr/local/bin | c:\bin}
  775. X    STRIP = {strip | tdstrip}
  776. X
  777. X    install: flex$(EXE)
  778. X        $(CP) flex$(EXE) $(BINDIR)
  779. X        $(STRIP) $(BINDIR)/flex$(EXE)
  780. X
  781. XRegards,
  782. X    few
  783. X
  784. Xfew@quad1.quad.com
  785. Xuunet!ccicpg!quad1!few
  786. X
  787. END_OF_FILE
  788. if test 6089 -ne `wc -c <'MISC/Turbo-C.notes'`; then
  789.     echo shar: \"'MISC/Turbo-C.notes'\" unpacked with wrong size!
  790. fi
  791. # end of 'MISC/Turbo-C.notes'
  792. fi
  793. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  794.   echo shar: Will not clobber existing file \"'Makefile'\"
  795. else
  796. echo shar: Extracting \"'Makefile'\" \(4876 characters\)
  797. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  798. X# make file for "flex" tool
  799. X
  800. X# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 90/05/26 17:28:44 vern Exp $ (LBL)
  801. X
  802. X# Porting considerations:
  803. X#
  804. X#    For System V Unix machines, add -DUSG to CFLAGS (if it's not
  805. X#         automatically defined)
  806. X#    For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
  807. X#    For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS.  Create \tmp if not present.
  808. X#         You will also want to rename flex.skel to something with a three
  809. X#         character extension, change SKELETON_FILE below appropriately,
  810. X#      See MSDOS.notes for more info.
  811. X#    For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
  812. X#    For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
  813. X#
  814. X#    For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
  815. X#
  816. X#    If your C compiler is ANSI standard but does not include the <stdlib.h>
  817. X#    header file (some installations of gcc have this problem), then add
  818. X#    -DDONT_HAVE_STDLIB_H to CFLAGS.
  819. X#
  820. X# By default, flex will be configured to generate 8-bit scanners only
  821. X# if the -8 flag is given.  If you want it to always generate 8-bit
  822. X# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS.  Note that doing
  823. X# so will double the size of all uncompressed scanners.
  824. X# 
  825. X# If on your system you have trouble building flex due to 8-bit
  826. X# character problems, remove the -8 from FLEX_FLAGS and the
  827. X# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
  828. X
  829. X
  830. X# the first time around use "make first_flex"
  831. X
  832. X
  833. X# Installation targeting.  Files will be installed under the tree rooted
  834. X# at DESTDIR.  User commands will be installed in BINDIR, library files
  835. X# in LIBDIR (which will be created if necessary), auxiliary files in
  836. X# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
  837. X# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
  838. X# preformatted versions will be installed if INSTALLMAN=cat.
  839. XDESTDIR =
  840. XBINDIR = /usr/local
  841. XLIBDIR = /usr/local/lib
  842. XAUXDIR = /usr/local/lib
  843. XMANDIR = /usr/man/manl
  844. XMANEXT = l
  845. XINSTALLMAN = man
  846. X
  847. X# MAKE = make
  848. X
  849. X
  850. XSKELETON_FILE = $(DESTDIR)$(AUXDIR)/flex.skel
  851. XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\"
  852. XCFLAGS = -O
  853. XLDFLAGS = -s
  854. X
  855. XCOMPRESSION =
  856. XFLEX_FLAGS = -ist8 -Sflex.skel
  857. X# which "flex" to use to generate scan.c from scan.l
  858. XFLEX = ./flex
  859. X# CC = cc
  860. X
  861. XAR = ar
  862. XRANLIB = ranlib
  863. X
  864. XFLEXOBJS = \
  865. X    ccl.o \
  866. X    dfa.o \
  867. X    ecs.o \
  868. X    gen.o \
  869. X    main.o \
  870. X    misc.o \
  871. X    nfa.o \
  872. X    parse.o \
  873. X    scan.o \
  874. X    sym.o \
  875. X    tblcmp.o \
  876. X    yylex.o
  877. X
  878. XFLEX_C_SOURCES = \
  879. X    ccl.c \
  880. X    dfa.c \
  881. X    ecs.c \
  882. X    gen.c \
  883. X    main.c \
  884. X    misc.c \
  885. X    nfa.c \
  886. X    parse.c \
  887. X    scan.c \
  888. X    sym.c \
  889. X    tblcmp.c \
  890. X    yylex.c
  891. X
  892. XFLEX_LIB_OBJS = \
  893. X    libmain.o
  894. X
  895. XFLEXLIB = flexlib.a
  896. X
  897. X
  898. Xall : flex $(FLEXLIB)
  899. X
  900. Xflex : $(FLEXOBJS)
  901. X    $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
  902. X
  903. Xfirst_flex:
  904. X    cp initscan.c scan.c
  905. X    $(MAKE) $(MFLAGS) flex
  906. X
  907. Xparse.h parse.c : parse.y
  908. X    $(YACC) -d parse.y
  909. X    @mv y.tab.c parse.c
  910. X    @mv y.tab.h parse.h
  911. X
  912. Xscan.c : scan.l
  913. X    $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c
  914. X
  915. Xscan.o : scan.c parse.h flexdef.h
  916. X
  917. Xmain.o : main.c flexdef.h
  918. X    $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
  919. X
  920. Xccl.o : ccl.c flexdef.h
  921. Xdfa.o : dfa.c flexdef.h
  922. Xecs.o : ecs.c flexdef.h
  923. Xgen.o : gen.c flexdef.h
  924. Xmisc.o : misc.c flexdef.h
  925. Xnfa.o : nfa.c flexdef.h
  926. Xparse.o : parse.c flexdef.h
  927. Xsym.o : sym.c flexdef.h
  928. Xtblcmp.o : tblcmp.c flexdef.h
  929. Xyylex.o : yylex.c flexdef.h
  930. X
  931. Xflex.man : flex.1
  932. X    nroff -man flex.1 >flex.man
  933. X
  934. X$(FLEXLIB) : $(FLEX_LIB_OBJS)
  935. X    $(AR) cru $(FLEXLIB) $(FLEX_LIB_OBJS)
  936. X
  937. Xlint : $(FLEX_C_SOURCES)
  938. X    lint $(FLEX_C_SOURCES) > flex.lint
  939. X
  940. Xdistrib :
  941. X    mv scan.c initscan.c
  942. X    chmod 444 initscan.c
  943. X    $(MAKE) $(MFLAGS) clean
  944. X
  945. Xinstall: flex $(DESTDIR)$(LIBDIR) flex.skel install.$(INSTALLMAN) install-lib
  946. X    install -s -m 755 flex $(DESTDIR)$(BINDIR)/flex
  947. X    install -c -m 644 flex.skel $(SKELETON_FILE)
  948. X
  949. Xinstall-lib: $(DESTDIR)$(LIBDIR) $(FLEXLIB)
  950. X    install -c -m 644 $(FLEXLIB) $(DESTDIR)$(LIBDIR)/libfl.a
  951. X    $(RANLIB) $(DESTDIR)$(LIBDIR)/libfl.a
  952. X
  953. X$(DESTDIR)$(LIBDIR):
  954. X    mkdir $@
  955. X
  956. Xinstall.man: flex.1 flexdoc.1
  957. X    install -c -m 644 flex.1 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
  958. X    install -c -m 644 flexdoc.1 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
  959. X
  960. Xinstall.cat: flex.1 flexdoc.1
  961. X    nroff -h -man flex.1 > $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
  962. X    nroff -h -man flexdoc.1 > $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
  963. X    chmod 644 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
  964. X    chmod 644 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
  965. X
  966. Xclean :
  967. X    rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags \
  968. X        $(FLEXLIB)
  969. X
  970. Xtags :
  971. X    ctags $(FLEX_C_SOURCES)
  972. X
  973. Xvms :    flex.man
  974. X    $(MAKE) $(MFLAGS) distrib
  975. X
  976. Xtest : flex
  977. X    ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
  978. X
  979. Xbigtest :
  980. X    rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
  981. X    rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
  982. X    rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
  983. X    rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
  984. X    rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
  985. X    rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
  986. X    rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
  987. X    rm -f scan.c ; $(MAKE)
  988. END_OF_FILE
  989. if test 4876 -ne `wc -c <'Makefile'`; then
  990.     echo shar: \"'Makefile'\" unpacked with wrong size!
  991. fi
  992. # end of 'Makefile'
  993. fi
  994. if test -f 'Makefile.amiga' -a "${1}" != "-c" ; then 
  995.   echo shar: Will not clobber existing file \"'Makefile.amiga'\"
  996. else
  997. echo shar: Extracting \"'Makefile.amiga'\" \(4524 characters\)
  998. sed "s/^X//" >'Makefile.amiga' <<'END_OF_FILE'
  999. X# make file for "flex" tool (modified to work with Lattice 5.05)
  1000. X
  1001. X# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 90/05/26 17:28:44 vern Exp $ (LBL)
  1002. X
  1003. X# Porting considerations:
  1004. X#
  1005. X#    For System V Unix machines, add -DUSG to CFLAGS (if it's not
  1006. X#         automatically defined)
  1007. X#    For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
  1008. X#    For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS.  Create \tmp if not present.
  1009. X#         You will also want to rename flex.skel to something with a three
  1010. X#         character extension, change SKELETON_FILE below appropriately,
  1011. X#      See MSDOS.notes for more info.
  1012. X#    For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
  1013. X#    For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
  1014. X#
  1015. X#    For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
  1016. X#
  1017. X#    If your C compiler is ANSI standard but does not include the <stdlib.h>
  1018. X#    header file (some installations of gcc have this problem), then add
  1019. X#    -DDONT_HAVE_STDLIB_H to CFLAGS.
  1020. X#
  1021. X# By default, flex will be configured to generate 8-bit scanners only
  1022. X# if the -8 flag is given.  If you want it to always generate 8-bit
  1023. X# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS.  Note that doing
  1024. X# so will double the size of all uncompressed scanners.
  1025. X# 
  1026. X# If on your system you have trouble building flex due to 8-bit
  1027. X# character problems, remove the -8 from FLEX_FLAGS and the
  1028. X# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
  1029. X
  1030. X
  1031. X# the first time around use "make first_flex"
  1032. X
  1033. X
  1034. X# Installation targeting.  Files will be installed under the tree rooted
  1035. X# at DESTDIR.  User commands will be installed in BINDIR, library files
  1036. X# in LIBDIR (which will be created if necessary), auxiliary files in
  1037. X# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
  1038. X# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
  1039. X# preformatted versions will be installed if INSTALLMAN=cat.
  1040. XDESTDIR =
  1041. XBINDIR = c:unix
  1042. XLIBDIR = s:
  1043. XAUXDIR = s:
  1044. XMANDIR = uuman:
  1045. XMANEXT = doc
  1046. XINSTALLMAN = man
  1047. X
  1048. X# MAKE = make
  1049. X
  1050. X
  1051. XSKELETON_FILE = $(DESTDIR)$(AUXDIR)flex.skel
  1052. X# Cannot get quotes to work correctly with AmigaDOS and LMK.
  1053. X# moved this define to flexdef.h (between ifdef AMIGA...endif) wpl 7/14/90
  1054. X#SKELFLAGS = -dDEFAULT_SKELETON_FILE="$(SKELETON_FILE)"
  1055. XSKELFLAGS = 
  1056. XCFLAGS = -O -cwus -dAMIGA -dUSG 
  1057. XLDFLAGS = -s
  1058. X
  1059. XCOMPRESSION =
  1060. XFLEX_FLAGS = -ist8 -Sflex.skel
  1061. X# which "flex" to use to generate scan.c from scan.l
  1062. XFLEX = flex
  1063. X# CC = cc
  1064. XYACC = bison
  1065. XMAKE = lmk
  1066. XMFLAGS = -f Makefile.amiga
  1067. X
  1068. XFLEXOBJS = \
  1069. X    ccl.o \
  1070. X    dfa.o \
  1071. X    ecs.o \
  1072. X    gen.o \
  1073. X    main.o \
  1074. X    misc.o \
  1075. X    nfa.o \
  1076. X    parse.o \
  1077. X    scan.o \
  1078. X    sym.o \
  1079. X    tblcmp.o \
  1080. X    yylex.o
  1081. X
  1082. XFLEX_C_SOURCES = \
  1083. X    ccl.c \
  1084. X    dfa.c \
  1085. X    ecs.c \
  1086. X    gen.c \
  1087. X    main.c \
  1088. X    misc.c \
  1089. X    nfa.c \
  1090. X    parse.c \
  1091. X    scan.c \
  1092. X    sym.c \
  1093. X    tblcmp.c \
  1094. X    yylex.c
  1095. X
  1096. Xall : flex 
  1097. X
  1098. Xflex : $(FLEXOBJS)
  1099. X        blink from lib:c.o $(FLEXOBJS) to flex lib lib:lc.lib lib:amiga.lib
  1100. X
  1101. Xfirst_flex:
  1102. X    copy initscan.c scan.c
  1103. X    $(MAKE) $(MFLAGS) flex
  1104. X
  1105. Xparse.h parse.c : parse.y
  1106. X    $(YACC) -d parse.y
  1107. X    @copy parse.tab.c parse.c
  1108. X    @copy parse.tab.h parse.h
  1109. X    @delete parse.tab.c
  1110. X    @delete parse.tab.h
  1111. X
  1112. Xscan.c : scan.l
  1113. X    $(FLEX) >scan.c $(FLEX_FLAGS) $(COMPRESSION) scan.l
  1114. X
  1115. Xscan.o : scan.c parse.h flexdef.h
  1116. X
  1117. Xmain.o : main.c flexdef.h
  1118. X    $(CC) $(CFLAGS) $(SKELFLAGS) main.c
  1119. X
  1120. Xccl.o : ccl.c flexdef.h
  1121. Xdfa.o : dfa.c flexdef.h
  1122. Xecs.o : ecs.c flexdef.h
  1123. Xgen.o : gen.c flexdef.h
  1124. Xmisc.o : misc.c flexdef.h
  1125. Xnfa.o : nfa.c flexdef.h
  1126. Xparse.o : parse.c flexdef.h
  1127. Xsym.o : sym.c flexdef.h
  1128. Xtblcmp.o : tblcmp.c flexdef.h
  1129. Xyylex.o : yylex.c flexdef.h
  1130. X
  1131. Xinstall : flex flex.skel
  1132. X    copy flex $(DESTDIR)$(BINDIR)/flex
  1133. X    copy flex.skel $(SKELETON_FILE)
  1134. X
  1135. X#install.man : flex.1 flexdoc.1
  1136. X#    install -c -m 644 flex.1 $(DESTDIR)$(MANDIR)flex.$(MANEXT)
  1137. X#    install -c -m 644 flexdoc.1 $(DESTDIR)$(MANDIR)flexdoc.$(MANEXT)
  1138. X
  1139. X#install.cat : flex.1 flexdoc.1
  1140. X#    nroff -h -man flex.1 > $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
  1141. X#    nroff -h -man flexdoc.1 > $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
  1142. X#    chmod 644 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
  1143. X#    chmod 644 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
  1144. X
  1145. X#clean :
  1146. X#    rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags \
  1147. X#        $(FLEXLIB)
  1148. X
  1149. X#test : flex
  1150. X#    ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
  1151. X
  1152. X#bigtest :
  1153. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
  1154. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
  1155. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
  1156. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
  1157. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
  1158. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
  1159. X#    rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
  1160. X#    rm -f scan.c ; $(MAKE)
  1161. END_OF_FILE
  1162. if test 4524 -ne `wc -c <'Makefile.amiga'`; then
  1163.     echo shar: \"'Makefile.amiga'\" unpacked with wrong size!
  1164. fi
  1165. # end of 'Makefile.amiga'
  1166. fi
  1167. if test -f 'README' -a "${1}" != "-c" ; then 
  1168.   echo shar: Will not clobber existing file \"'README'\"
  1169. else
  1170. echo shar: Extracting \"'README'\" \(1599 characters\)
  1171. sed "s/^X//" >'README' <<'END_OF_FILE'
  1172. X// $Header: /usr/fsys/odin/a/vern/flex/RCS/README,v 2.8 90/05/26 17:31:27 vern Exp $
  1173. X
  1174. XThis is release 2.3 of flex - a full release.
  1175. X
  1176. XThe flex distribution consists of the following files:
  1177. X
  1178. X    README        This message
  1179. X
  1180. X    Makefile
  1181. X    flexdef.h
  1182. X    parse.y
  1183. X    scan.l
  1184. X    ccl.c
  1185. X    dfa.c
  1186. X    ecs.c        flex sources
  1187. X    gen.c
  1188. X    main.c
  1189. X    misc.c
  1190. X    nfa.c
  1191. X    sym.c
  1192. X    tblcmp.c
  1193. X    yylex.c
  1194. X
  1195. X    libmain.c    flex library (-lfl) source
  1196. X
  1197. X    initscan.c    pre-flex'd version of scan.l
  1198. X
  1199. X    flex.skel    skeleton for generated scanners
  1200. X
  1201. X    flexdoc.1    full user documentation
  1202. X    flex.1        reference documentation
  1203. X
  1204. X    Changes        Differences between this release and the previous one
  1205. X
  1206. X    COPYING        flex's copyright
  1207. X
  1208. X    MISC/        a directory containing miscellaneous porting-related
  1209. X            notes (for Atari, MS-DOS, Turbo-C, and VMS)
  1210. X
  1211. X
  1212. XDecide where you want to keep flex.skel (suggestion:  /usr/local/lib),
  1213. Xbut don't move it there yet.  Edit "Makefile" and change the definition
  1214. Xof SKELETON_FILE to reflect the full pathname of flex.skel.
  1215. X
  1216. XRead the "Porting considerations" note in the Makefile and make
  1217. Xthe necessary changes.
  1218. X
  1219. XTo make flex for the first time, use:
  1220. X
  1221. X    make first_flex
  1222. X
  1223. Xwhich uses the pre-generated copy of the flex scanner (the scanner
  1224. Xitself is written using flex).
  1225. X
  1226. XAssuming it builds successfully, you can test it using
  1227. X
  1228. X    make test
  1229. X
  1230. XThe "diff" should not show any differences.
  1231. X
  1232. XIf you're feeling adventurous, issue "make bigtest" and be prepared
  1233. Xto wait a while.
  1234. X
  1235. XInstall flex using:
  1236. X
  1237. X    make install
  1238. X
  1239. X
  1240. XPlease send problems and feedback to:
  1241. X
  1242. X    vern@cs.cornell.edu
  1243. X    decvax!cornell!vern
  1244. X
  1245. X    Vern Paxson
  1246. X    CS Department
  1247. X    4126 Upson Hall
  1248. X    Cornell University
  1249. X    Ithaca, NY 14853-7501
  1250. END_OF_FILE
  1251. if test 1599 -ne `wc -c <'README'`; then
  1252.     echo shar: \"'README'\" unpacked with wrong size!
  1253. fi
  1254. # end of 'README'
  1255. fi
  1256. if test -f 'ccl.c' -a "${1}" != "-c" ; then 
  1257.   echo shar: Will not clobber existing file \"'ccl.c'\"
  1258. else
  1259. echo shar: Extracting \"'ccl.c'\" \(4115 characters\)
  1260. sed "s/^X//" >'ccl.c' <<'END_OF_FILE'
  1261. X/* ccl - routines for character classes */
  1262. X
  1263. X/*-
  1264. X * Copyright (c) 1990 The Regents of the University of California.
  1265. X * All rights reserved.
  1266. X *
  1267. X * This code is derived from software contributed to Berkeley by
  1268. X * Vern Paxson.
  1269. X * 
  1270. X * The United States Government has rights in this work pursuant
  1271. X * to contract no. DE-AC03-76SF00098 between the United States
  1272. X * Department of Energy and the University of California.
  1273. X *
  1274. X * Redistribution and use in source and binary forms are permitted provided
  1275. X * that: (1) source distributions retain this entire copyright notice and
  1276. X * comment, and (2) distributions including binaries display the following
  1277. X * acknowledgement:  ``This product includes software developed by the
  1278. X * University of California, Berkeley and its contributors'' in the
  1279. X * documentation or other materials provided with the distribution and in
  1280. X * all advertising materials mentioning features or use of this software.
  1281. X * Neither the name of the University nor the names of its contributors may
  1282. X * be used to endorse or promote products derived from this software without
  1283. X * specific prior written permission.
  1284. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1285. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1286. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1287. X */
  1288. X
  1289. X#ifndef lint
  1290. Xstatic char rcsid[] =
  1291. X    "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/ccl.c,v 2.5 90/06/27 23:48:13 vern Exp $ (LBL)";
  1292. X#endif
  1293. X
  1294. X#include "flexdef.h"
  1295. X
  1296. X/* ccladd - add a single character to a ccl
  1297. X *
  1298. X * synopsis
  1299. X *    int cclp;
  1300. X *    int ch;
  1301. X *    ccladd( cclp, ch );
  1302. X */
  1303. X
  1304. Xvoid ccladd( cclp, ch )
  1305. Xint cclp;
  1306. Xint ch;
  1307. X
  1308. X    {
  1309. X    int ind, len, newpos, i;
  1310. X
  1311. X    len = ccllen[cclp];
  1312. X    ind = cclmap[cclp];
  1313. X
  1314. X    /* check to see if the character is already in the ccl */
  1315. X
  1316. X    for ( i = 0; i < len; ++i )
  1317. X    if ( ccltbl[ind + i] == ch )
  1318. X        return;
  1319. X
  1320. X    newpos = ind + len;
  1321. X
  1322. X    if ( newpos >= current_max_ccl_tbl_size )
  1323. X    {
  1324. X    current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
  1325. X
  1326. X    ++num_reallocs;
  1327. X
  1328. X    ccltbl = reallocate_character_array( ccltbl, current_max_ccl_tbl_size );
  1329. X    }
  1330. X
  1331. X    ccllen[cclp] = len + 1;
  1332. X    ccltbl[newpos] = ch;
  1333. X    }
  1334. X
  1335. X
  1336. X/* cclinit - make an empty ccl
  1337. X *
  1338. X * synopsis
  1339. X *    int cclinit();
  1340. X *    new_ccl = cclinit();
  1341. X */
  1342. X
  1343. Xint cclinit()
  1344. X
  1345. X    {
  1346. X    if ( ++lastccl >= current_maxccls )
  1347. X    {
  1348. X    current_maxccls += MAX_CCLS_INCREMENT;
  1349. X
  1350. X    ++num_reallocs;
  1351. X
  1352. X    cclmap = reallocate_integer_array( cclmap, current_maxccls );
  1353. X    ccllen = reallocate_integer_array( ccllen, current_maxccls );
  1354. X    cclng = reallocate_integer_array( cclng, current_maxccls );
  1355. X    }
  1356. X
  1357. X    if ( lastccl == 1 )
  1358. X    /* we're making the first ccl */
  1359. X    cclmap[lastccl] = 0;
  1360. X
  1361. X    else
  1362. X    /* the new pointer is just past the end of the last ccl.  Since
  1363. X     * the cclmap points to the \first/ character of a ccl, adding the
  1364. X     * length of the ccl to the cclmap pointer will produce a cursor
  1365. X     * to the first free space
  1366. X     */
  1367. X    cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
  1368. X
  1369. X    ccllen[lastccl] = 0;
  1370. X    cclng[lastccl] = 0;    /* ccl's start out life un-negated */
  1371. X
  1372. X    return ( lastccl );
  1373. X    }
  1374. X
  1375. X
  1376. X/* cclnegate - negate a ccl
  1377. X *
  1378. X * synopsis
  1379. X *    int cclp;
  1380. X *    cclnegate( ccl );
  1381. X */
  1382. X
  1383. Xvoid cclnegate( cclp )
  1384. Xint cclp;
  1385. X
  1386. X    {
  1387. X    cclng[cclp] = 1;
  1388. X    }
  1389. X
  1390. X
  1391. X/* list_character_set - list the members of a set of characters in CCL form
  1392. X *
  1393. X * synopsis
  1394. X *     int cset[CSIZE];
  1395. X *     FILE *file;
  1396. X *     list_character_set( cset );
  1397. X *
  1398. X * writes to the given file a character-class representation of those
  1399. X * characters present in the given set.  A character is present if it
  1400. X * has a non-zero value in the set array.
  1401. X */
  1402. X
  1403. Xvoid list_character_set( file, cset )
  1404. XFILE *file;
  1405. Xint cset[];
  1406. X
  1407. X    {
  1408. X    register int i;
  1409. X    char *readable_form();
  1410. X
  1411. X    putc( '[', file );
  1412. X
  1413. X    for ( i = 0; i < csize; ++i )
  1414. X    {
  1415. X    if ( cset[i] )
  1416. X        {
  1417. X        register int start_char = i;
  1418. X
  1419. X        putc( ' ', file );
  1420. X
  1421. X        fputs( readable_form( i ), file );
  1422. X
  1423. X        while ( ++i < csize && cset[i] )
  1424. X        ;
  1425. X
  1426. X        if ( i - 1 > start_char )
  1427. X        /* this was a run */
  1428. X        fprintf( file, "-%s", readable_form( i - 1 ) );
  1429. X
  1430. X        putc( ' ', file );
  1431. X        }
  1432. X    }
  1433. X
  1434. X    putc( ']', file );
  1435. X    }
  1436. END_OF_FILE
  1437. if test 4115 -ne `wc -c <'ccl.c'`; then
  1438.     echo shar: \"'ccl.c'\" unpacked with wrong size!
  1439. fi
  1440. # end of 'ccl.c'
  1441. fi
  1442. if test -f 'ecs.c' -a "${1}" != "-c" ; then 
  1443.   echo shar: Will not clobber existing file \"'ecs.c'\"
  1444. else
  1445. echo shar: Extracting \"'ecs.c'\" \(8758 characters\)
  1446. sed "s/^X//" >'ecs.c' <<'END_OF_FILE'
  1447. X/* ecs - equivalence class routines */
  1448. X
  1449. X/*-
  1450. X * Copyright (c) 1990 The Regents of the University of California.
  1451. X * All rights reserved.
  1452. X *
  1453. X * This code is derived from software contributed to Berkeley by
  1454. X * Vern Paxson.
  1455. X * 
  1456. X * The United States Government has rights in this work pursuant
  1457. X * to contract no. DE-AC03-76SF00098 between the United States
  1458. X * Department of Energy and the University of California.
  1459. X *
  1460. X * Redistribution and use in source and binary forms are permitted provided
  1461. X * that: (1) source distributions retain this entire copyright notice and
  1462. X * comment, and (2) distributions including binaries display the following
  1463. X * acknowledgement:  ``This product includes software developed by the
  1464. X * University of California, Berkeley and its contributors'' in the
  1465. X * documentation or other materials provided with the distribution and in
  1466. X * all advertising materials mentioning features or use of this software.
  1467. X * Neither the name of the University nor the names of its contributors may
  1468. X * be used to endorse or promote products derived from this software without
  1469. X * specific prior written permission.
  1470. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1471. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1472. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1473. X */
  1474. X
  1475. X#ifndef lint
  1476. Xstatic char rcsid[] =
  1477. X    "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/ecs.c,v 2.5 90/06/27 23:48:17 vern Exp $ (LBL)";
  1478. X#endif
  1479. X
  1480. X#include "flexdef.h"
  1481. X
  1482. X/* ccl2ecl - convert character classes to set of equivalence classes
  1483. X *
  1484. X * synopsis
  1485. X *    ccl2ecl();
  1486. X */
  1487. X
  1488. Xvoid ccl2ecl()
  1489. X
  1490. X    {
  1491. X    int i, ich, newlen, cclp, ccls, cclmec;
  1492. X
  1493. X    for ( i = 1; i <= lastccl; ++i )
  1494. X    {
  1495. X    /* we loop through each character class, and for each character
  1496. X     * in the class, add the character's equivalence class to the
  1497. X     * new "character" class we are creating.  Thus when we are all
  1498. X     * done, character classes will really consist of collections
  1499. X     * of equivalence classes
  1500. X     */
  1501. X
  1502. X    newlen = 0;
  1503. X    cclp = cclmap[i];
  1504. X
  1505. X    for ( ccls = 0; ccls < ccllen[i]; ++ccls )
  1506. X        {
  1507. X        ich = ccltbl[cclp + ccls];
  1508. X        cclmec = ecgroup[ich];
  1509. X
  1510. X        if ( xlation && cclmec < 0 )
  1511. X        {
  1512. X        /* special hack--if we're doing %t tables then it's
  1513. X         * possible that no representative of this character's
  1514. X         * equivalence class is in the ccl.  So waiting till
  1515. X         * we see the representative would be disastrous.  Instead,
  1516. X         * we add this character's equivalence class anyway, if it's
  1517. X         * not already present.
  1518. X         */
  1519. X        int j;
  1520. X
  1521. X        /* this loop makes this whole process n^2; but we don't
  1522. X         * really care about %t performance anyway
  1523. X         */
  1524. X        for ( j = 0; j < newlen; ++j )
  1525. X            if ( ccltbl[cclp + j] == -cclmec )
  1526. X            break;
  1527. X
  1528. X        if ( j >= newlen )
  1529. X            { /* no representative yet, add this one in */
  1530. X            ccltbl[cclp + newlen] = -cclmec;
  1531. X            ++newlen;
  1532. X            }
  1533. X        }
  1534. X
  1535. X        else if ( cclmec > 0 )
  1536. X        {
  1537. X        ccltbl[cclp + newlen] = cclmec;
  1538. X        ++newlen;
  1539. X        }
  1540. X        }
  1541. X
  1542. X    ccllen[i] = newlen;
  1543. X    }
  1544. X    }
  1545. X
  1546. X
  1547. X/* cre8ecs - associate equivalence class numbers with class members
  1548. X *
  1549. X * synopsis
  1550. X *    int cre8ecs();
  1551. X *    number of classes = cre8ecs( fwd, bck, num );
  1552. X *
  1553. X *  fwd is the forward linked-list of equivalence class members.  bck
  1554. X *  is the backward linked-list, and num is the number of class members.
  1555. X *
  1556. X *  Returned is the number of classes.
  1557. X */
  1558. X
  1559. Xint cre8ecs( fwd, bck, num )
  1560. Xint fwd[], bck[], num;
  1561. X
  1562. X    {
  1563. X    int i, j, numcl;
  1564. X
  1565. X    numcl = 0;
  1566. X
  1567. X    /* create equivalence class numbers.  From now on, abs( bck(x) )
  1568. X     * is the equivalence class number for object x.  If bck(x)
  1569. X     * is positive, then x is the representative of its equivalence
  1570. X     * class.
  1571. X     */
  1572. X    for ( i = 1; i <= num; ++i )
  1573. X    if ( bck[i] == NIL )
  1574. X        {
  1575. X        bck[i] = ++numcl;
  1576. X        for ( j = fwd[i]; j != NIL; j = fwd[j] )
  1577. X        bck[j] = -numcl;
  1578. X        }
  1579. X
  1580. X    return ( numcl );
  1581. X    }
  1582. X
  1583. X
  1584. X/* ecs_from_xlation - associate equivalence class numbers using %t table
  1585. X *
  1586. X * synopsis
  1587. X *    numecs = ecs_from_xlation( ecmap );
  1588. X *
  1589. X *  Upon return, ecmap will map each character code to its equivalence
  1590. X *  class.  The mapping will be positive if the character is the representative
  1591. X *  of its class, negative otherwise.
  1592. X *
  1593. X *  Returns the number of equivalence classes used.
  1594. X */
  1595. X
  1596. Xint ecs_from_xlation( ecmap )
  1597. Xint ecmap[];
  1598. X
  1599. X    {
  1600. X    int i;
  1601. X    int nul_is_alone = false;
  1602. X    int did_default_xlation_class = false;
  1603. X
  1604. X    if ( xlation[0] != 0 )
  1605. X    {
  1606. X    /* if NUL shares its translation with other characters, choose one
  1607. X     * of the other characters as the representative for the equivalence
  1608. X     * class.  This allows a cheap test later to see whether we can
  1609. X     * do away with NUL's equivalence class.
  1610. X     */
  1611. X    for ( i = 1; i < csize; ++i )
  1612. X        if ( xlation[i] == -xlation[0] )
  1613. X        {
  1614. X        xlation[i] = xlation[0];
  1615. X        ecmap[0] = -xlation[0];
  1616. X        break;
  1617. X        }
  1618. X
  1619. X    if ( i >= csize )
  1620. X        /* didn't find a companion character--remember this fact */
  1621. X        nul_is_alone = true;
  1622. X    }
  1623. X
  1624. X    for ( i = 1; i < csize; ++i )
  1625. X    if ( xlation[i] == 0 )
  1626. X        {
  1627. X        if ( did_default_xlation_class )
  1628. X        ecmap[i] = -num_xlations;
  1629. X        
  1630. X        else
  1631. X        {
  1632. X        /* make an equivalence class for those characters not
  1633. X         * specified in the %t table
  1634. X         */
  1635. X        ++num_xlations;
  1636. X        ecmap[i] = num_xlations;
  1637. X        did_default_xlation_class = true;
  1638. X        }
  1639. X        }
  1640. X
  1641. X    else
  1642. X        ecmap[i] = xlation[i];
  1643. X
  1644. X    if ( nul_is_alone )
  1645. X    /* force NUL's equivalence class to be the last one */
  1646. X    {
  1647. X    ++num_xlations;
  1648. X    ecmap[0] = num_xlations;
  1649. X
  1650. X    /* there's actually a bug here: if someone is fanatic enough to
  1651. X     * put every character in its own translation class, then right
  1652. X     * now we just promoted NUL's equivalence class to be csize + 1;
  1653. X     * we can handle NUL's class number being == csize (by instead
  1654. X     * putting it in its own table), but we can't handle some *other*
  1655. X     * character having to be put in its own table, too.  So in
  1656. X     * this case we bail out.
  1657. X     */
  1658. X    if ( num_xlations > csize )
  1659. X        flexfatal( "too many %t classes!" );
  1660. X    }
  1661. X
  1662. X    return num_xlations;
  1663. X    }
  1664. X
  1665. X
  1666. X/* mkeccl - update equivalence classes based on character class xtions
  1667. X *
  1668. X * synopsis
  1669. X *    Char ccls[];
  1670. X *    int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping;
  1671. X *    mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping );
  1672. X *
  1673. X * where ccls contains the elements of the character class, lenccl is the
  1674. X * number of elements in the ccl, fwd is the forward link-list of equivalent
  1675. X * characters, bck is the backward link-list, and llsiz size of the link-list
  1676. X *
  1677. X * NUL_mapping is the value which NUL (0) should be mapped to.
  1678. X */
  1679. X
  1680. Xvoid mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping )
  1681. XChar ccls[];
  1682. Xint lenccl, fwd[], bck[], llsiz, NUL_mapping;
  1683. X
  1684. X    {
  1685. X    int cclp, oldec, newec;
  1686. X    int cclm, i, j;
  1687. X    static unsigned char cclflags[CSIZE];    /* initialized to all '\0' */
  1688. X
  1689. X    /* note that it doesn't matter whether or not the character class is
  1690. X     * negated.  The same results will be obtained in either case.
  1691. X     */
  1692. X
  1693. X    cclp = 0;
  1694. X
  1695. X    while ( cclp < lenccl )
  1696. X    {
  1697. X    cclm = ccls[cclp];
  1698. X
  1699. X    if ( NUL_mapping && cclm == 0 )
  1700. X        cclm = NUL_mapping;
  1701. X
  1702. X    oldec = bck[cclm];
  1703. X    newec = cclm;
  1704. X
  1705. X    j = cclp + 1;
  1706. X
  1707. X    for ( i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i] )
  1708. X        { /* look for the symbol in the character class */
  1709. X        for ( ; j < lenccl; ++j )
  1710. X        {
  1711. X        register int ccl_char;
  1712. X
  1713. X        if ( NUL_mapping && ccls[j] == 0 )
  1714. X            ccl_char = NUL_mapping;
  1715. X        else
  1716. X            ccl_char = ccls[j];
  1717. X
  1718. X        if ( ccl_char > i )
  1719. X            break;
  1720. X
  1721. X        if ( ccl_char == i && ! cclflags[j] )
  1722. X            {
  1723. X            /* we found an old companion of cclm in the ccl.
  1724. X             * link it into the new equivalence class and flag it as
  1725. X             * having been processed
  1726. X             */
  1727. X
  1728. X            bck[i] = newec;
  1729. X            fwd[newec] = i;
  1730. X            newec = i;
  1731. X            cclflags[j] = 1;    /* set flag so we don't reprocess */
  1732. X
  1733. X            /* get next equivalence class member */
  1734. X            /* continue 2 */
  1735. X            goto next_pt;
  1736. X            }
  1737. X        }
  1738. X
  1739. X        /* symbol isn't in character class.  Put it in the old equivalence
  1740. X         * class
  1741. X         */
  1742. X
  1743. X        bck[i] = oldec;
  1744. X
  1745. X        if ( oldec != NIL )
  1746. X        fwd[oldec] = i;
  1747. X
  1748. X        oldec = i;
  1749. Xnext_pt:
  1750. X        ;
  1751. X        }
  1752. X
  1753. X    if ( bck[cclm] != NIL || oldec != bck[cclm] )
  1754. X        {
  1755. X        bck[cclm] = NIL;
  1756. X        fwd[oldec] = NIL;
  1757. X        }
  1758. X
  1759. X    fwd[newec] = NIL;
  1760. X
  1761. X    /* find next ccl member to process */
  1762. X
  1763. X    for ( ++cclp; cclflags[cclp] && cclp < lenccl; ++cclp )
  1764. X        {
  1765. X        /* reset "doesn't need processing" flag */
  1766. X        cclflags[cclp] = 0;
  1767. X        }
  1768. X    }
  1769. X    }
  1770. X
  1771. X
  1772. X/* mkechar - create equivalence class for single character
  1773. X *
  1774. X * synopsis
  1775. X *    int tch, fwd[], bck[];
  1776. X *    mkechar( tch, fwd, bck );
  1777. X */
  1778. X
  1779. Xvoid mkechar( tch, fwd, bck )
  1780. Xint tch, fwd[], bck[];
  1781. X
  1782. X    {
  1783. X    /* if until now the character has been a proper subset of
  1784. X     * an equivalence class, break it away to create a new ec
  1785. X     */
  1786. X
  1787. X    if ( fwd[tch] != NIL )
  1788. X    bck[fwd[tch]] = bck[tch];
  1789. X
  1790. X    if ( bck[tch] != NIL )
  1791. X    fwd[bck[tch]] = fwd[tch];
  1792. X
  1793. X    fwd[tch] = NIL;
  1794. X    bck[tch] = NIL;
  1795. X    }
  1796. END_OF_FILE
  1797. if test 8758 -ne `wc -c <'ecs.c'`; then
  1798.     echo shar: \"'ecs.c'\" unpacked with wrong size!
  1799. fi
  1800. # end of 'ecs.c'
  1801. fi
  1802. if test -f 'flexdoc.uu.ac' -a "${1}" != "-c" ; then 
  1803.   echo shar: Will not clobber existing file \"'flexdoc.uu.ac'\"
  1804. else
  1805. echo shar: Extracting \"'flexdoc.uu.ac'\" \(813 characters\)
  1806. sed "s/^X//" >'flexdoc.uu.ac' <<'END_OF_FILE'
  1807. XM($]V92!%=V5R;&ED("AE=V5R;&ED0&UI>F%R+D1O0U,N554N4T4I+@H*("`@M
  1808. XM("!4:&ES('=O<FL@=V%S('!R:6UA<FEL>2!D;VYE('=H96X@22!W87,@(&%T@
  1809. XM("!T:&4@(%)E86P@(%1I;64*("`@("!3>7-T96US("!'<F]U<"!A="!T:&4@Y
  1810. XM3&%W<F5N8V4@0F5R:V5L97D@3&%B;W)A=&]R>2!I;B!"97)K92T*("`@("!L&
  1811. XM97DL($-!+B`@36%N>2`@=&AA;FMS("!T;R`@86QL("!T:&5R92`@9F]R("!TI
  1812. XM:&4@('-U<'!O<G0@($D*("`@("!R96-E:79E9"X*"B`@("`@4V5N9"!C;VUM<
  1813. XM96YT<R!T;SH*"B`@("`@("`@("!697)N(%!A>'-O;@H@("`@("`@("`@0V]MH
  1814. XM<'5T97(@4V-I96YC92!$97!A<G1M96YT"B`@("`@("`@("`T,3(V(%5P<V]N*
  1815. XM($AA;&P*("`@("`@("`@($-O<FYE;&P@56YI=F5R<VET>0H@("`@("`@("`@F
  1816. XM271H86-A+"!.62`Q-#@U,RTW-3`Q"@H@("`@("`@("`@=F5R;D!C<RYC;W)NA
  1817. XM96QL+F5D=0H@("`@("`@("`@9&5C=F%X(6-O<FYE;&PA=F5R;@H*"@H*"@H*J
  1818. XM"@H*5F5R<VEO;B`R+C,@("`@("`@("!,87-T(&-H86YG93H@,C8@36%Y(#$Y$
  1819. X;.3`@("`@("`@("`@("`@("`@("`@,S4*"@H*9
  1820. X``
  1821. Xend
  1822. Xsize 81522
  1823. END_OF_FILE
  1824. if test 813 -ne `wc -c <'flexdoc.uu.ac'`; then
  1825.     echo shar: \"'flexdoc.uu.ac'\" unpacked with wrong size!
  1826. fi
  1827. # end of 'flexdoc.uu.ac'
  1828. fi
  1829. if test -f 'libmain.c' -a "${1}" != "-c" ; then 
  1830.   echo shar: Will not clobber existing file \"'libmain.c'\"
  1831. else
  1832. echo shar: Extracting \"'libmain.c'\" \(256 characters\)
  1833. sed "s/^X//" >'libmain.c' <<'END_OF_FILE'
  1834. X/* libmain - flex run-time support library "main" function */
  1835. X
  1836. X/* $Header: /usr/fsys/odin/a/vern/flex/RCS/libmain.c,v 1.2 90/05/26 16:50:08 vern Exp $ */
  1837. X
  1838. Xextern int yylex();
  1839. X
  1840. Xint main( argc, argv )
  1841. Xint argc;
  1842. Xchar *argv[];
  1843. X
  1844. X    {
  1845. X    return yylex();
  1846. X    }
  1847. END_OF_FILE
  1848. if test 256 -ne `wc -c <'libmain.c'`; then
  1849.     echo shar: \"'libmain.c'\" unpacked with wrong size!
  1850. fi
  1851. # end of 'libmain.c'
  1852. fi
  1853. if test -f 'parse.h' -a "${1}" != "-c" ; then 
  1854.   echo shar: Will not clobber existing file \"'parse.h'\"
  1855. else
  1856. echo shar: Extracting \"'parse.h'\" \(527 characters\)
  1857. sed "s/^X//" >'parse.h' <<'END_OF_FILE'
  1858. X
  1859. X#ifndef YYLTYPE
  1860. Xtypedef
  1861. X  struct yyltype
  1862. X    {
  1863. X      int timestamp;
  1864. X      int first_line;
  1865. X      int first_column;
  1866. X      int last_line;
  1867. X      int last_column;
  1868. X      char *text;
  1869. X   }
  1870. X  yyltype;
  1871. X
  1872. X#define YYLTYPE yyltype
  1873. X#endif
  1874. X
  1875. X#define    YYACCEPT    return(0)
  1876. X#define    YYABORT    return(1)
  1877. X#define    YYERROR    goto yyerrlab
  1878. X#ifndef YYSTYPE
  1879. X#define YYSTYPE int
  1880. X#endif
  1881. X#define    CHAR    258
  1882. X#define    NUMBER    259
  1883. X#define    SECTEND    260
  1884. X#define    SCDECL    261
  1885. X#define    XSCDECL    262
  1886. X#define    WHITESPACE    263
  1887. X#define    NAME    264
  1888. X#define    PREVCCL    265
  1889. X#define    EOF_OP    266
  1890. X
  1891. END_OF_FILE
  1892. if test 527 -ne `wc -c <'parse.h'`; then
  1893.     echo shar: \"'parse.h'\" unpacked with wrong size!
  1894. fi
  1895. # end of 'parse.h'
  1896. fi
  1897. if test -f 'sym.c' -a "${1}" != "-c" ; then 
  1898.   echo shar: Will not clobber existing file \"'sym.c'\"
  1899. else
  1900. echo shar: Extracting \"'sym.c'\" \(7527 characters\)
  1901. sed "s/^X//" >'sym.c' <<'END_OF_FILE'
  1902. X/* sym - symbol table routines */
  1903. X
  1904. X/*-
  1905. X * Copyright (c) 1990 The Regents of the University of California.
  1906. X * All rights reserved.
  1907. X *
  1908. X * This code is derived from software contributed to Berkeley by
  1909. X * Vern Paxson.
  1910. X * 
  1911. X * The United States Government has rights in this work pursuant
  1912. X * to contract no. DE-AC03-76SF00098 between the United States
  1913. X * Department of Energy and the University of California.
  1914. X *
  1915. X * Redistribution and use in source and binary forms are permitted provided
  1916. X * that: (1) source distributions retain this entire copyright notice and
  1917. X * comment, and (2) distributions including binaries display the following
  1918. X * acknowledgement:  ``This product includes software developed by the
  1919. X * University of California, Berkeley and its contributors'' in the
  1920. X * documentation or other materials provided with the distribution and in
  1921. X * all advertising materials mentioning features or use of this software.
  1922. X * Neither the name of the University nor the names of its contributors may
  1923. X * be used to endorse or promote products derived from this software without
  1924. X * specific prior written permission.
  1925. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1926. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1927. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1928. X */
  1929. X
  1930. X#ifndef lint
  1931. Xstatic char rcsid[] =
  1932. X    "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/sym.c,v 2.4 90/06/27 23:48:36 vern Exp $ (LBL)";
  1933. X#endif
  1934. X
  1935. X#include "flexdef.h"
  1936. X
  1937. X
  1938. X/* declare functions that have forward references */
  1939. X
  1940. Xint hashfunct PROTO((register char[], int));
  1941. X
  1942. X
  1943. Xstruct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
  1944. Xstruct hash_entry *sctbl[START_COND_HASH_SIZE];
  1945. Xstruct hash_entry *ccltab[CCL_HASH_SIZE];
  1946. X
  1947. Xstruct hash_entry *findsym();
  1948. X
  1949. X
  1950. X/* addsym - add symbol and definitions to symbol table
  1951. X *
  1952. X * synopsis
  1953. X *    char sym[], *str_def;
  1954. X *    int int_def;
  1955. X *    hash_table table;
  1956. X *    int table_size;
  1957. X *    0 / -1 = addsym( sym, def, int_def, table, table_size );
  1958. X *
  1959. X * -1 is returned if the symbol already exists, and the change not made.
  1960. X */
  1961. X
  1962. Xint addsym( sym, str_def, int_def, table, table_size )
  1963. Xregister char sym[];
  1964. Xchar *str_def;
  1965. Xint int_def;
  1966. Xhash_table table;
  1967. Xint table_size;
  1968. X
  1969. X    {
  1970. X    int hash_val = hashfunct( sym, table_size );
  1971. X    register struct hash_entry *sym_entry = table[hash_val];
  1972. X    register struct hash_entry *new_entry;
  1973. X    register struct hash_entry *successor;
  1974. X
  1975. X    while ( sym_entry )
  1976. X    {
  1977. X    if ( ! strcmp( sym, sym_entry->name ) )
  1978. X        { /* entry already exists */
  1979. X        return ( -1 );
  1980. X        }
  1981. X    
  1982. X    sym_entry = sym_entry->next;
  1983. X    }
  1984. X
  1985. X    /* create new entry */
  1986. X    new_entry = (struct hash_entry *) malloc( sizeof( struct hash_entry ) );
  1987. X
  1988. X    if ( new_entry == NULL )
  1989. X    flexfatal( "symbol table memory allocation failed" );
  1990. X
  1991. X    if ( (successor = table[hash_val]) )
  1992. X    {
  1993. X    new_entry->next = successor;
  1994. X    successor->prev = new_entry;
  1995. X    }
  1996. X    else
  1997. X    new_entry->next = NULL;
  1998. X
  1999. X    new_entry->prev = NULL;
  2000. X    new_entry->name = sym;
  2001. X    new_entry->str_val = str_def;
  2002. X    new_entry->int_val = int_def;
  2003. X
  2004. X    table[hash_val] = new_entry;
  2005. X
  2006. X    return ( 0 );
  2007. X    }
  2008. X
  2009. X
  2010. X/* cclinstal - save the text of a character class
  2011. X *
  2012. X * synopsis
  2013. X *    Char ccltxt[];
  2014. X *    int cclnum;
  2015. X *    cclinstal( ccltxt, cclnum );
  2016. X */
  2017. X
  2018. Xvoid cclinstal( ccltxt, cclnum )
  2019. XChar ccltxt[];
  2020. Xint cclnum;
  2021. X
  2022. X    {
  2023. X    /* we don't bother checking the return status because we are not called
  2024. X     * unless the symbol is new
  2025. X     */
  2026. X    Char *copy_unsigned_string();
  2027. X
  2028. X    (void) addsym( (char *) copy_unsigned_string( ccltxt ), (char *) 0, cclnum,
  2029. X           ccltab, CCL_HASH_SIZE );
  2030. X    }
  2031. X
  2032. X
  2033. X/* ccllookup - lookup the number associated with character class text
  2034. X *
  2035. X * synopsis
  2036. X *    Char ccltxt[];
  2037. X *    int ccllookup, cclval;
  2038. X *    cclval/0 = ccllookup( ccltxt );
  2039. X */
  2040. X
  2041. Xint ccllookup( ccltxt )
  2042. XChar ccltxt[];
  2043. X
  2044. X    {
  2045. X    return ( findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val );
  2046. X    }
  2047. X
  2048. X
  2049. X/* findsym - find symbol in symbol table
  2050. X *
  2051. X * synopsis
  2052. X *    char sym[];
  2053. X *    hash_table table;
  2054. X *    int table_size;
  2055. X *    struct hash_entry *sym_entry, *findsym();
  2056. X *    sym_entry = findsym( sym, table, table_size );
  2057. X */
  2058. X
  2059. Xstruct hash_entry *findsym( sym, table, table_size )
  2060. Xregister char sym[];
  2061. Xhash_table table;
  2062. Xint table_size;
  2063. X
  2064. X    {
  2065. X    register struct hash_entry *sym_entry = table[hashfunct( sym, table_size )];
  2066. X    static struct hash_entry empty_entry =
  2067. X    {
  2068. X    (struct hash_entry *) 0, (struct hash_entry *) 0, NULL, NULL, 0,
  2069. X    } ;
  2070. X
  2071. X    while ( sym_entry )
  2072. X    {
  2073. X    if ( ! strcmp( sym, sym_entry->name ) )
  2074. X        return ( sym_entry );
  2075. X    sym_entry = sym_entry->next;
  2076. X    }
  2077. X
  2078. X    return ( &empty_entry );
  2079. X    }
  2080. X
  2081. X    
  2082. X/* hashfunct - compute the hash value for "str" and hash size "hash_size"
  2083. X *
  2084. X * synopsis
  2085. X *    char str[];
  2086. X *    int hash_size, hash_val;
  2087. X *    hash_val = hashfunct( str, hash_size );
  2088. X */
  2089. X
  2090. Xint hashfunct( str, hash_size )
  2091. Xregister char str[];
  2092. Xint hash_size;
  2093. X
  2094. X    {
  2095. X    register int hashval;
  2096. X    register int locstr;
  2097. X
  2098. X    hashval = 0;
  2099. X    locstr = 0;
  2100. X
  2101. X    while ( str[locstr] )
  2102. X    hashval = ((hashval << 1) + str[locstr++]) % hash_size;
  2103. X
  2104. X    return ( hashval );
  2105. X    }
  2106. X
  2107. X
  2108. X/* ndinstal - install a name definition
  2109. X *
  2110. X * synopsis
  2111. X *    char nd[];
  2112. X *    Char def[];
  2113. X *    ndinstal( nd, def );
  2114. X */
  2115. X
  2116. Xvoid ndinstal( nd, def )
  2117. Xchar nd[];
  2118. XChar def[];
  2119. X
  2120. X    {
  2121. X    char *copy_string();
  2122. X    Char *copy_unsigned_string();
  2123. X
  2124. X    if ( addsym( copy_string( nd ), (char *) copy_unsigned_string( def ), 0,
  2125. X         ndtbl, NAME_TABLE_HASH_SIZE ) )
  2126. X    synerr( "name defined twice" );
  2127. X    }
  2128. X
  2129. X
  2130. X/* ndlookup - lookup a name definition
  2131. X *
  2132. X * synopsis
  2133. X *    char nd[], *def;
  2134. X *    char *ndlookup();
  2135. X *    def/NULL = ndlookup( nd );
  2136. X */
  2137. X
  2138. XChar *ndlookup( nd )
  2139. Xchar nd[];
  2140. X
  2141. X    {
  2142. X    return ( (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val );
  2143. X    }
  2144. X
  2145. X
  2146. X/* scinstal - make a start condition
  2147. X *
  2148. X * synopsis
  2149. X *    char str[];
  2150. X *    int xcluflg;
  2151. X *    scinstal( str, xcluflg );
  2152. X *
  2153. X * NOTE
  2154. X *    the start condition is Exclusive if xcluflg is true
  2155. X */
  2156. X
  2157. Xvoid scinstal( str, xcluflg )
  2158. Xchar str[];
  2159. Xint xcluflg;
  2160. X
  2161. X    {
  2162. X    char *copy_string();
  2163. X
  2164. X    /* bit of a hack.  We know how the default start-condition is
  2165. X     * declared, and don't put out a define for it, because it
  2166. X     * would come out as "#define 0 1"
  2167. X     */
  2168. X    /* actually, this is no longer the case.  The default start-condition
  2169. X     * is now called "INITIAL".  But we keep the following for the sake
  2170. X     * of future robustness.
  2171. X     */
  2172. X
  2173. X    if ( strcmp( str, "0" ) )
  2174. X    printf( "#define %s %d\n", str, lastsc );
  2175. X
  2176. X    if ( ++lastsc >= current_max_scs )
  2177. X    {
  2178. X    current_max_scs += MAX_SCS_INCREMENT;
  2179. X
  2180. X    ++num_reallocs;
  2181. X
  2182. X    scset = reallocate_integer_array( scset, current_max_scs );
  2183. X    scbol = reallocate_integer_array( scbol, current_max_scs );
  2184. X    scxclu = reallocate_integer_array( scxclu, current_max_scs );
  2185. X    sceof = reallocate_integer_array( sceof, current_max_scs );
  2186. X    scname = reallocate_char_ptr_array( scname, current_max_scs );
  2187. X    actvsc = reallocate_integer_array( actvsc, current_max_scs );
  2188. X    }
  2189. X
  2190. X    scname[lastsc] = copy_string( str );
  2191. X
  2192. X    if ( addsym( scname[lastsc], (char *) 0, lastsc,
  2193. X         sctbl, START_COND_HASH_SIZE ) )
  2194. X    format_pinpoint_message( "start condition %s declared twice", str );
  2195. X
  2196. X    scset[lastsc] = mkstate( SYM_EPSILON );
  2197. X    scbol[lastsc] = mkstate( SYM_EPSILON );
  2198. X    scxclu[lastsc] = xcluflg;
  2199. X    sceof[lastsc] = false;
  2200. X    }
  2201. X
  2202. X
  2203. X/* sclookup - lookup the number associated with a start condition
  2204. X *
  2205. X * synopsis
  2206. X *    char str[], scnum;
  2207. X *    int sclookup;
  2208. X *    scnum/0 = sclookup( str );
  2209. X */
  2210. X
  2211. Xint sclookup( str )
  2212. Xchar str[];
  2213. X
  2214. X    {
  2215. X    return ( findsym( str, sctbl, START_COND_HASH_SIZE )->int_val );
  2216. X    }
  2217. END_OF_FILE
  2218. if test 7527 -ne `wc -c <'sym.c'`; then
  2219.     echo shar: \"'sym.c'\" unpacked with wrong size!
  2220. fi
  2221. # end of 'sym.c'
  2222. fi
  2223. if test -f 'yylex.c' -a "${1}" != "-c" ; then 
  2224.   echo shar: Will not clobber existing file \"'yylex.c'\"
  2225. else
  2226. echo shar: Extracting \"'yylex.c'\" \(4244 characters\)
  2227. sed "s/^X//" >'yylex.c' <<'END_OF_FILE'
  2228. X/* yylex - scanner front-end for flex */
  2229. X
  2230. X/*-
  2231. X * Copyright (c) 1990 The Regents of the University of California.
  2232. X * All rights reserved.
  2233. X *
  2234. X * This code is derived from software contributed to Berkeley by
  2235. X * Vern Paxson.
  2236. X * 
  2237. X * The United States Government has rights in this work pursuant
  2238. X * to contract no. DE-AC03-76SF00098 between the United States
  2239. X * Department of Energy and the University of California.
  2240. X *
  2241. X * Redistribution and use in source and binary forms are permitted provided
  2242. X * that: (1) source distributions retain this entire copyright notice and
  2243. X * comment, and (2) distributions including binaries display the following
  2244. X * acknowledgement:  ``This product includes software developed by the
  2245. X * University of California, Berkeley and its contributors'' in the
  2246. X * documentation or other materials provided with the distribution and in
  2247. X * all advertising materials mentioning features or use of this software.
  2248. X * Neither the name of the University nor the names of its contributors may
  2249. X * be used to endorse or promote products derived from this software without
  2250. X * specific prior written permission.
  2251. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  2252. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  2253. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  2254. X */
  2255. X
  2256. X#ifndef lint
  2257. Xstatic char rcsid[] =
  2258. X    "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/yylex.c,v 2.5 90/06/27 23:48:40 vern Exp $ (LBL)";
  2259. X#endif
  2260. X
  2261. X#include <ctype.h>
  2262. X#include "flexdef.h"
  2263. X#include "parse.h"
  2264. X
  2265. X
  2266. X/* ANSI C does not guarantee that isascii() is defined */
  2267. X#ifndef isascii
  2268. X#define isascii(c) ((c) <= 0177)
  2269. X#endif
  2270. X
  2271. X
  2272. X/* yylex - scan for a regular expression token
  2273. X *
  2274. X * synopsis
  2275. X *
  2276. X *   token = yylex();
  2277. X *
  2278. X *     token - return token found
  2279. X */
  2280. X
  2281. Xint yylex()
  2282. X
  2283. X    {
  2284. X    int toktype;
  2285. X    static int beglin = false;
  2286. X
  2287. X    if ( eofseen )
  2288. X    toktype = EOF;
  2289. X    else
  2290. X    toktype = flexscan();
  2291. X
  2292. X    if ( toktype == EOF || toktype == 0 )
  2293. X    {
  2294. X    eofseen = 1;
  2295. X
  2296. X    if ( sectnum == 1 )
  2297. X        {
  2298. X        synerr( "premature EOF" );
  2299. X        sectnum = 2;
  2300. X        toktype = SECTEND;
  2301. X        }
  2302. X
  2303. X    else if ( sectnum == 2 )
  2304. X        {
  2305. X        sectnum = 3;
  2306. X        toktype = 0;
  2307. X        }
  2308. X
  2309. X    else
  2310. X        toktype = 0;
  2311. X    }
  2312. X
  2313. X    if ( trace )
  2314. X    {
  2315. X    if ( beglin )
  2316. X        {
  2317. X        fprintf( stderr, "%d\t", num_rules + 1 );
  2318. X        beglin = 0;
  2319. X        }
  2320. X
  2321. X    switch ( toktype )
  2322. X        {
  2323. X        case '<':
  2324. X        case '>':
  2325. X        case '^':
  2326. X        case '$':
  2327. X        case '"':
  2328. X        case '[':
  2329. X        case ']':
  2330. X        case '{':
  2331. X        case '}':
  2332. X        case '|':
  2333. X        case '(':
  2334. X        case ')':
  2335. X        case '-':
  2336. X        case '/':
  2337. X        case '\\':
  2338. X        case '?':
  2339. X        case '.':
  2340. X        case '*':
  2341. X        case '+':
  2342. X        case ',':
  2343. X        (void) putc( toktype, stderr );
  2344. X        break;
  2345. X
  2346. X        case '\n':
  2347. X        (void) putc( '\n', stderr );
  2348. X
  2349. X        if ( sectnum == 2 )
  2350. X            beglin = 1;
  2351. X
  2352. X        break;
  2353. X
  2354. X        case SCDECL:
  2355. X        fputs( "%s", stderr );
  2356. X        break;
  2357. X
  2358. X        case XSCDECL:
  2359. X        fputs( "%x", stderr );
  2360. X        break;
  2361. X
  2362. X        case WHITESPACE:
  2363. X        (void) putc( ' ', stderr );
  2364. X        break;
  2365. X
  2366. X        case SECTEND:
  2367. X        fputs( "%%\n", stderr );
  2368. X
  2369. X        /* we set beglin to be true so we'll start
  2370. X         * writing out numbers as we echo rules.  flexscan() has
  2371. X         * already assigned sectnum
  2372. X         */
  2373. X
  2374. X        if ( sectnum == 2 )
  2375. X            beglin = 1;
  2376. X
  2377. X        break;
  2378. X
  2379. X        case NAME:
  2380. X        fprintf( stderr, "'%s'", nmstr );
  2381. X        break;
  2382. X
  2383. X        case CHAR:
  2384. X        switch ( yylval )
  2385. X            {
  2386. X            case '<':
  2387. X            case '>':
  2388. X            case '^':
  2389. X            case '$':
  2390. X            case '"':
  2391. X            case '[':
  2392. X            case ']':
  2393. X            case '{':
  2394. X            case '}':
  2395. X            case '|':
  2396. X            case '(':
  2397. X            case ')':
  2398. X            case '-':
  2399. X            case '/':
  2400. X            case '\\':
  2401. X            case '?':
  2402. X            case '.':
  2403. X            case '*':
  2404. X            case '+':
  2405. X            case ',':
  2406. X            fprintf( stderr, "\\%c", yylval );
  2407. X            break;
  2408. X
  2409. X            default:
  2410. X            if ( ! isascii( yylval ) || ! isprint( yylval ) )
  2411. X                fprintf( stderr, "\\%.3o", yylval );
  2412. X            else
  2413. X                (void) putc( yylval, stderr );
  2414. X            break;
  2415. X            }
  2416. X            
  2417. X        break;
  2418. X
  2419. X        case NUMBER:
  2420. X        fprintf( stderr, "%d", yylval );
  2421. X        break;
  2422. X
  2423. X        case PREVCCL:
  2424. X        fprintf( stderr, "[%d]", yylval );
  2425. X        break;
  2426. X
  2427. X        case EOF_OP:
  2428. X        fprintf( stderr, "<<EOF>>" );
  2429. X        break;
  2430. X
  2431. X        case 0:
  2432. X        fprintf( stderr, "End Marker" );
  2433. X        break;
  2434. X
  2435. X        default:
  2436. X        fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
  2437. X             toktype, yylval );
  2438. X        break;
  2439. X        }
  2440. X    }
  2441. X        
  2442. X    return ( toktype );
  2443. X    }
  2444. END_OF_FILE
  2445. if test 4244 -ne `wc -c <'yylex.c'`; then
  2446.     echo shar: \"'yylex.c'\" unpacked with wrong size!
  2447. fi
  2448. # end of 'yylex.c'
  2449. fi
  2450. echo shar: End of archive 1 \(of 13\).
  2451. cp /dev/null ark1isdone
  2452. MISSING=""
  2453. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  2454.     if test ! -f ark${I}isdone ; then
  2455.     MISSING="${MISSING} ${I}"
  2456.     fi
  2457. done
  2458. if test "${MISSING}" = "" ; then
  2459.     echo You have unpacked all 13 archives.
  2460.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2461. else
  2462.     echo You still need to unpack the following archives:
  2463.     echo "        " ${MISSING}
  2464. fi
  2465. ##  End of shell archive.
  2466. exit 0
  2467. -- 
  2468. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2469. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2470. Post requests for sources, and general discussion to comp.sys.amiga.
  2471.